/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙，邂逅框架梦]
 * 
 * https://zhiqim.org/project/zhiqim_framework/zhiqim_httpd.htm
 *
 * Zhiqim Httpd is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package org.zhiqim.httpd;

import java.nio.ByteBuffer;

import org.zhiqim.kernel.annotation.AnAlias;
import org.zhiqim.kernel.constants.HttpConstants;

/**
 * HTTPD常量定义
 *
 * @version v1.0.0 @author zouzhigang 2014-3-21 新建与整理
 */
@AnAlias("HttpdConstants")
public interface HttpdConstants extends HttpConstants
{
    //浏览器相关参数
    public String _ZHTTPD_                              = "zhiqim_httpd_v8.0.1";
    public String _TOKEN_                               = "_token_";
    public String _MSIE_                                = "msie";
    public String _MSTRIDENT_                           = "trident";
    public String _FIREFOX_                             = "firefox";
    public String _WEBKIT_                              = "webkit";
    public String _CHROME_                              = "chrome";
    public String _SAFARI_                              = "safari";
    public String _MOBILE_                              = "mobile";
    public String _WWW_                                 = "www";
    public String _MICROMESSAGER_                       = "micromessenger";
    
    public String _OPTIONS_                             = "OPTIONS";
    public String _ACCESS_CONTROL_REQUEST_HEADERS_      = "Access-Control-Request-Headers";
    public String _ACCESS_CONTROL_ALLOW_HEADERS_        = "Access-Control-Allow-Headers";
    public String _ACCESS_CONTROL_ALLOW_METHODS_        = "Access-Control-Allow-Methods";
    public String _ACCESS_CONTROL_ALLOW_ORIGIN_         = "Access-Control-Allow-Origin";
    public String _ACCESS_CONTROL_MAX_AGE_              = "Access-Control-Max-Age";

    //默认的HTTP环境和会话管理器
    public String _HTTP_CONTEXT_CLASS_                  = "org.zhiqim.httpd.context.ZmlContext";
    public String _HTTP_SESSION_MANAGER_DEFAULT_        = "org.zhiqim.httpd.sessioner.HashSessionManager";
    public String _HTTP_SESSION_USER_                   = "org.zhiqim.httpd.HttpSessionUser";
    public String _HTTP_SESSION_IP_                     = "org.zhiqim.httpd.HttpSession.sessionIp";
    public String _HTTP_SESSION_UA_                     = "org.zhiqim.httpd.HttpSession.userAgent";
    public String _HTTP_REQUEST_PARAM_MATCH_            = "org.zhiqim.httpd.HttpRequest.paramMatch";
    
    //常用的SSL协议|算法和类型
    public String SSL_PROTOCOL                          = "TLS";    //协议
    public String SSL_ALGORITHM                         = "SunX509";//算法
    public String SSL_KEYSTORE_TYPE                     = "JKS";    //类型
    
    //常用的三个文件放到包里
    public String _PATH_FAVICON_ICO_                    = "/org/zhiqim/httpd/resources/favicon.ico";
    public String _PATH_CROSSDOMAIN_XML_                = "/org/zhiqim/httpd/resources/crossdomain.xml";
    public String _PATH_MIME_PROPERTIES_                = "/org/zhiqim/httpd/resources/mime.properties";

    //默认提供的处理器
    public String _PATH_FAVICON_                        = "/favicon.ico";
    public String _PATH_CROSSDOMAIN_                    = "/crossdomain.xml";
    public String _MAX_AGE_3600_PUBLIC_                 = "max-age=3600, public";
    
    //上下文环境的常量
    public String _CONTEXT_                             = "context";
    public String _SESSION_                             = "session";
    public String _SESSION_ID_                          = "sessionId";
    public String _SESSION_USER_                        = "sessionUser";
    public String _SESSION_NAME_                        = "sessionName";
    public String _REQUEST_                             = "request";
    public String _RESPONSE_                            = "response";
    public String _LOG_                                 = "log";
    public String _AIO_                                 = "AIO";
    public String _BIO_                                 = "BIO";
    public String _NIO_                                 = "NIO";
    public ByteBuffer _HELLO_N_                         = ByteBuffer.wrap(_ZHTTPD_.getBytes());
    
    //上下文环境的常量（知启蒙特有的定义）
    public String _ZHIQIM_CLIENT_TYPE_                  = "zhiqimClientType";
    public String _DEFAULT_WEB_SOCKET_PROTOCOL_         = "defaultWebSocketProtocol";
    
    //重定向支持的三个常量定义
    public String _REDIRECT_HISTORY_                    = "-1";         //后退，调用window.history.back();
    public String _REDIRECT_CLOSE_WINDOW_               = "closeWindow";//关闭窗口，调用window.close();
    public String _REDIRECT_CLOSE_DIALOG_               = "closeDialog";//关闭对话框，调用parent.Z.Dialog.close();
    
    //表单参数中两个重要标志
    public String _PARAM_CALL_FRAME_                    = "zCallFrame";
    public String _PARAM_FORM_INDEX_                    = "zFormIndex";
    public String _PARAM_DIALOG_FRAME_                  = "zDialogFrame";
    
    //HTTP协议长度定义
    public int _MAX_LINE_LEN_                           = 8 * KiB;
    public int _MAX_HEADER_LINE_                        = 128;
    public int _MAX_CONTENT_LEN_                        = 8 * MiB;
    public int _MAX_CHUNKED_SIZE_                       = MiB;
    public int _MAX_EXPIRES_                            = 3600;
    
    //标记连接处理进度
    public int _01_CREATE_                              = 1; //连接被listner创建
    public int _02_PARSE_HEADER_                        = 2; //解析请求头
    public int _03_CHECK_HEADER_                        = 3; //检查请求头
    public int _04_QUERY_CONTEXT_                       = 4; //查找Context
    public int _05_QUERY_HANDLER_                       = 5; //查找Handler
    public int _06_PARSE_CONTENT_                       = 6; //解析请求内容
    public int _07_HANDLER_BEGIN_                       = 7; //请求被Handler处理开始
    public int _08_INTERCEPTOR_                         = 8; //请求被Interceptor处理
    public int _09_ACTION_                              = 9; //请求被Action处理
    public int _10_HANDLER_END_                         = 10;//请求被Handler处理结束
    public int _11_COMMITTED_                           = 11;//提交响应完成
    public int _12_FINISHED_                            = 12;//结束请求处理
    
    public String _01_STEP_DESC_                        = "[创建]";
    public String _02_STEP_DESC_                        = "[解析请求头]";
    public String _03_STEP_DESC_                        = "[检查请求头]";
    public String _04_STEP_DESC_                        = "[查找上下文环境]";
    public String _05_STEP_DESC_                        = "[查找处理器]";
    public String _06_STEP_DESC_                        = "[解析请求内容]";
    public String _07_STEP_DESC_                        = "[处理开始]";
    public String _08_STEP_DESC_                        = "[拦截器处理中]";
    public String _09_STEP_DESC_                        = "[业务处理中]";
    public String _10_STEP_DESC_                        = "[处理完成]";
    public String _11_STEP_DESC_                        = "[正在提交]";
    public String _12_STEP_DESC_                        = "[提交完成]";
    
    //HTTP服务配置
    public String _SERVER_CONTEXT_                      = "context";
    
    //HTTP监听配置
    public String _LISTEN_SCHEME_                       = "scheme";
    public String _LISTEN_PORT_                         = "port";
    public String _LISTEN_IO_                           = "io";
    public String _LISTEN_IP_ADDRESS_                   = "ipAddress";
    public String _LISTEN_SO_ITMEOUT_                   = "soTimeout";
    public String _LISTEN_SO_LINGER_                    = "soLinger";
    public String _LISTEN_SO_RECV_BUF_                  = "soRecvBuf";
    public String _LISTEN_SO_SEND_BUF_                  = "soSendBuf";
    public String _LISTEN_SO_IDLE_TIME_                 = "soIdleTime";
    public String _LISTEN_PO_MIN_SIZE_                  = "poMinSize";
    public String _LISTEN_PO_MAX_SIZE_                  = "poMaxSize";
    public String _LISTEN_PO_IDLE_TIME_                 = "poIdleTime";
    public String _LISTEN_PO_QUEUE_SIZE_                = "poQueueSize";
    public String _LISTEN_ACCESS_LOG_                   = "accessLog";
    
    //HTTPS证书相关
    public String _KEY_STORE_PATH_                      = "keystorePath";
    public String _KEY_STORE_PASS_                      = "keystorePass";
    public String _TRUST_STORE_PATH_                    = "truststorePath";
    public String _TRUST_STORE_PASS_                    = "truststorePass";
    public String _CLIENT_AUTH_                         = "clientAuth";
    
    //HTTP Context配置
    public String _CONTEXT_DOMAIN_                      = "domain";
    public String _CONTEXT_PATH_                        = "path";
    public String _CONTEXT_CLASS_                       = "class";
    public String _CONTEXT_RESOURCE_TYPE_               = "resourceType";
    public String _CONTEXT_RESOURCE_PATH_               = "resourcePath";
    public String _CONTEXT_WELCOME_URL_                 = "welcomeUrl";
    public String _CONTEXT_NOT_FOUND_URL_               = "notFoundUrl";
    public String _CONTEXT_MAX_CONTENT_LEN_             = "maxContentLength";
    public String _CONTEXT_CHUNK_SIZE_                  = "chunkSize";
    public String _CONTEXT_EXPIRES_                     = "expires";
    public String _CONTEXT_FILTER_                      = "filter";
    public String _CONTEXT_ENCODING_                    = "encoding";
    
    public String _CONTEXT_OPTIONS_HEADERS_             = "optionsHeaders";
    public String _CONTEXT_OPTIONS_METHODS_             = "optionsMethods";
    public String _CONTEXT_OPTIONS_ORIGIN_              = "optionsOrigin";
    public String _CONTEXT_OPTIONS_MAX_AGE_             = "optionsMaxAge";
}
